﻿<%@ Page Title="" Language="C#" MasterPageFile="~/TsSite.Master" AutoEventWireup="true" CodeBehind="CapacityPlanning.aspx.cs" Inherits="TireService.Web.View.ServiceView.CapacityPlanning" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxHiddenField" TagPrefix="dx" %>

<%@ Register src="../../UserControls/ucEditServiceNote.ascx" tagname="ucEditServiceNote" tagprefix="uc2" %>



<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <!-- Loading panel -->
    <dx:ASPxLoadingPanel ID="LoadingPanel" Text="Vent venligst..." ClientInstanceName="LoadingPanel" runat="server" Modal="True">
    </dx:ASPxLoadingPanel>

    <table cellpadding="0" cellspacing="2" border="0">
        <tr>
            <td>
                <img id="imgServicePlanning" alt="" src="~/Images/Medium/stopwatch.png" runat="server" style="width: 32px; height: 32px" />
            </td>
            <td valign="middle">
                <h3><asp:Label ID="lblServicePlanning" runat="server" Text="Booking"></asp:Label></h3>
            </td>
        </tr>
    </table>

    <table>
        <tr>
            <td>Lager</td>
            <td>Kørselsområde</td>
            <td>Vis antal</td>
            <td colspan="2">Søg på regnr</td>
        </tr>
        <tr>
            <td>
                <dx:ASPxComboBox ID="ddlContainer" ClientInstanceName="ddlContainer" runat="server">
                    <ClientSideEvents SelectedIndexChanged="function(s, e) { OnSelectedContainerChanged(s)  }" />
                </dx:ASPxComboBox>
            </td>
            <td>
                <dx:ASPxComboBox ID="ddlArea" ClientInstanceName="ddlArea" runat="server" OnCallback="ddlArea_Callback">
                    <ClientSideEvents SelectedIndexChanged="function(s, e) { OnSelectedAreaChanged(s)  }" />
                </dx:ASPxComboBox>
            </td>
            <td>
                <dx:ASPxComboBox ID="ddlPageResultCount" ClientInstanceName="ddlPageResultCount" runat="server" AutoPostBack="false">
                    <Items>
                        <dx:ListEditItem Selected="True" Value="0" Text="10 resultater" />
                        <dx:ListEditItem Value="1" Text="20 resultater" />
                        <dx:ListEditItem Value="2" Text="50 resultater" />
                        <dx:ListEditItem Value="3" Text="100 resultater" />
                        <dx:ListEditItem Value="4" Text="Alle resultater" />
                    </Items>
                </dx:ASPxComboBox>
            </td>
            <td>
                <dx:ASPxTextBox ID="txtRegistrationNumber" ClientInstanceName="txtRegistrationNumber" runat="server" Width="100px" NullText="Søg på regnr">
                    <ValidationSettings CausesValidation="true" ValidationGroup="SearchOnRegistrationNumber" RequiredField-IsRequired="true" RequiredField-ErrorText="Indtast regnr" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                        <RequiredField IsRequired="True" ErrorText="Indtast regnr"></RequiredField>
                    </ValidationSettings>
                    <ClientSideEvents KeyDown="function(s, e) {if(ASPxClientUtils.GetKeyCode(e.htmlEvent) ===  ASPxKey.Enter) SearchOnRegistrationNumber();}" />
                </dx:ASPxTextBox>
            </td>
            <td>
                <dx:ASPxButton ID="btnRegistrationNumberSearch" ClientInstanceName="btnRegistrationNumberSearch" runat="server" Text="Søg" AutoPostBack="False" UseSubmitBehavior="False">
                    <ClientSideEvents Click="function(s, e) { SearchOnRegistrationNumber(); }" />
                </dx:ASPxButton>
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td valign="top">
                <!-- Javascript: ServiceDrive Task Gridview -->
                <script language="javascript" type="text/javascript">

                    var TaskId = 0;

                    // Function that runs when dropdown container selection changed
                    function OnSelectedContainerChanged(dropdownlist) {
                        ddlArea.PerformCallback(dropdownlist.GetValue());
                        //gvServiceDriveTasks.PerformCallback(dropdownlist.GetValue());
                        gvServiceDriveTasks.PerformCallback();
                    }

                    function OnSelectedAreaChanged() { 
                        // TODO: Implement functions
                    }

                    function SearchOnRegistrationNumber() {
                        // TODO: Implement functions
                    }

                    // Function for handling callback error
                    function CallBackError(s, e) {
                        // NOTE: 01-06-2013 - Outcommeted due to not needed
                        //alert('Fejl opstod: ' + e.message);
                    }

                    // Function that runs when task is selected in gridview
                    function SelectedServiceDriveTaskChanged(s, e) {
                        // Get taskid
                        //gvServiceDriveTasks.GetRowValues(gvServiceDriveTasks.GetFocusedRowIndex(), 'TaskId', SetSelectedServiceDriveTaskId);
                    }

                    // Function that selects a booked service in gridview for editing/changing
                    function SelectServiceDriveTask(index) {
                        gvServiceDriveTasks.GetRowValues(index, 'TaskId', SetSelectedServiceDriveTaskId);

//                        var taskid = gvServiceDriveTasks.GetRowValuesByKeyValue(serviceid, 'TaskId');
//                        SetSelectedServiceDriveTaskId(taskid);
                    }

                    function SetSelectedServiceDriveTaskId(value) {                        
                        if (value == null) {
                            // Nothing - something went wrong
                            //TaskId = 0;
                        }
                        else {
                            TaskId = value;

                            // Show selected task details and possible date depending on address selection
                            callbackSelectAddressPanel.PerformCallback(TaskId);

                            // Show loadingpanel while doing server postback
                            LoadingPanel.Show();
                        }
                    }

                </script>

                <!-- Contains overview of pending servicedrives -->
                <dx:ASPxGridView ID="gvServiceDriveTasks" runat="server" Caption="Servicekørsel opgaver" 
                    ClientInstanceName="gvServiceDriveTasks" Width="450px" KeyFieldName="TaskId" AutoGenerateColumns="False" 
                    EnableCallBacks="True" OnCustomCallback="gvServiceDriveTasks_CustomCallback">
                    <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                    <Border BorderWidth="0px" />
                    <Settings ShowVerticalScrollBar="true" ShowHeaderFilterButton="true" ShowGroupPanel="false" ShowFilterRow="true" />
                    <SettingsPager AlwaysShowPager="False" PageSize="100" Position="Bottom">
                        <Summary 
                            AllPagesText="Sider: {0} - {1} ({2} servicekørsler)" 
                            Text="Side {0} af {1} ({2} servicekørsler)" />
                    </SettingsPager>
                    <SettingsBehavior ProcessFocusedRowChangedOnServer="false" AllowFocusedRow="true" ConfirmDelete="True" AllowGroup="false" AllowDragDrop="false" />
                    <ClientSideEvents FocusedRowChanged="function(s, e) { SelectedServiceDriveTaskChanged() }" 
                                        CustomButtonClick="function(s, e) {
	                                    if(e.buttonID == 'selectServiceTask'){
                                                            
                                                             SelectServiceDriveTask(e.visibleIndex);
                                                         }
                                        }" />

                    <Columns>
                        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                            <HeaderTemplate>
                                <input type="checkbox" onclick="gvServiceDriveTasks.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                            </HeaderTemplate>
                            <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                HorizontalAlign="Center">
                            <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                            </HeaderStyle>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataColumn FieldName="TaskId" Visible="false" VisibleIndex="3" Caption="TaskId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="CarId" Visible="false" VisibleIndex="4" Caption="CarId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="CustomerId" Visible="false" VisibleIndex="5" Caption="CustomerId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="TireSetId" Visible="false" VisibleIndex="6" Caption="TireSetId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="ContainerId" Visible="false" VisibleIndex="7" Caption="ContainerId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryLongitude" Visible="false" VisibleIndex="8" Caption="PrimaryLongitude">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryLatitude" Visible="false" VisibleIndex="9" Caption="PrimaryLatitude">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="SecondaryLongitude" Visible="false" VisibleIndex="10" Caption="SecondaryLongitude">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="SecondaryLatitude" Visible="false" VisibleIndex="11" Caption="SecondaryLatitude">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataTextColumn FieldName="ContainerNumber" VisibleIndex="12" Visible="false" Caption="Lager">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="13" Caption="Reg.nr.">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="14" Caption="Kundenr">
                            <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomerData.aspx?CustomerId={0}" TextField="CustomerId" Target="_blank">
                            </PropertiesHyperLinkEdit>
                        </dx:GridViewDataHyperLinkColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryAddress" VisibleIndex="15" Visible="false" Caption="Adresse">
                        </dx:GridViewDataColumn>
                        <%--<dx:GridViewDataColumn FieldName="PrimaryZipCode" VisibleIndex="16" Caption="Postnr" ToolTip='<%# Eval("PrimaryAddress") + " " + Eval("PrimaryCity") %>'>
                        </dx:GridViewDataColumn>--%>
                        <dx:GridViewDataColumn FieldName="PrimaryZipCode" VisibleIndex="16" Caption="Postnr">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryCity" VisibleIndex="17" Caption="By">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryCountryId" VisibleIndex="18" Caption="PrimaryCountryId" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="SecondaryAddress" VisibleIndex="19" Caption="Sek. Adr" Visible="false">
                        </dx:GridViewDataColumn>          
                        <%--<dx:GridViewDataColumn FieldName="SecondaryZipCode" VisibleIndex="20" Caption="Sek. Postnr" ToolTip='<%# Eval("SecondaryAddress") + " " + Eval("SecondaryCity") %>'>
                        </dx:GridViewDataColumn>--%> 
                        <dx:GridViewDataColumn FieldName="SecondaryZipCode" VisibleIndex="20" Caption="Sek. Postnr">
                        </dx:GridViewDataColumn>         
                        <dx:GridViewDataColumn FieldName="SecondaryCity" VisibleIndex="21" Caption="Sek. By" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="Distance" VisibleIndex="22" Caption="Km pri." ToolTip="Afstand fra lager til kundens primære adresse" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="DistanceSecondary" VisibleIndex="23" Caption="Km sek." ToolTip="Afstand fra lager til kundens sekundære adresse" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewCommandColumn VisibleIndex="24">
                            <CustomButtons>
                                <dx:GridViewCommandColumnCustomButton ID="selectServiceTask" Text="Vælg">
                                </dx:GridViewCommandColumnCustomButton>
                            </CustomButtons>
                        </dx:GridViewCommandColumn>
                    </Columns>
                    <Templates>
                        <DetailRow>
                            Opgavedetaljer
                            <br />
                            <dx:ASPxGridView ID="gvTaskDetail" ClientInstanceName="gvTaskDetail" runat="server" KeyFieldName="TaskDetailId"
                                Width="100%" OnBeforePerformDataSelect="gvTaskDetail_DataSelect">
                                <Columns>
                                    <dx:GridViewDataColumn FieldName="TaskDetailId" Caption="Id" VisibleIndex="1" />
                                    <dx:GridViewDataColumn FieldName="TaskDetailTypeId" Caption="Type" Visible="false" VisibleIndex="2" />
                                    <dx:GridViewDataColumn FieldName="Description" Caption="Beskrivelse" VisibleIndex="2" />
                                    <dx:GridViewDataColumn FieldName="EstimatedTime" Caption="Estimeret tid" VisibleIndex="2" />
                                    <dx:GridViewDataColumn FieldName="Amount" Caption="Antal" VisibleIndex="3" />
                                    <dx:GridViewDataColumn FieldName="NoteToEmployee" Caption="Note" VisibleIndex="4" />
                                    <dx:GridViewDataColumn FieldName="Completed" Caption="Afsluttet" VisibleIndex="5" />
                                    <dx:GridViewDataColumn FieldName="Cancelled" Caption="Annulleret" VisibleIndex="6" />
                                </Columns>
                            </dx:ASPxGridView>
                        </DetailRow>
                    </Templates>
                    <SettingsDetail ShowDetailRow="true" />                                            
                </dx:ASPxGridView>
            </td>
        </tr>
        <tr>
            <td valign="top">
                <!-- Contains details on selected servicedrive and possible booking dates wizard -->

                <!-- Javascript: Select Address Panel -->
                <script language="javascript" type="text/javascript">

                    function OnSelectAddressPanelComplete(s, e) {
                        // Hide loadingpanel after postback
                        LoadingPanel.Hide();

                        // Show select address panel
                        callbackSelectAddressPanel.SetVisible(true);
                    }

                    // Function for handling GUI when selecting an address in address dropdown
                    function OnSelectAddressChanged(s, e) {
                        var SelectedAddress = ddlSelectAddress.GetValue();
                        var Address = ddlSelectAddress.GetText();
                        Address = Address.split("|");

                        if (SelectedAddress == 0) {
                            // Primary address has been selected
                            // Hide and Disable fields
                            pManualAddress.SetVisible(false);
                            txtAddress.SetEnabled(false);
                            ddlZipCode.SetEnabled(false);

                            // Load address text
                            txtAddress.SetText(Address[0]);
                            ddlZipCode.SetValue(Address[1]);

                            // Show available dates for selected address
                            ShowDates();
                        }
                        if (SelectedAddress == 1) {
                            // Secondary address has been selected
                            // Hide and Disable fields
                            pManualAddress.SetVisible(false);
                            txtAddress.SetEnabled(false);
                            ddlZipCode.SetEnabled(false);

                            // Load address text
                            txtAddress.SetText(Address[0]);
                            ddlZipCode.SetValue(Address[1]);

                            // Show available dates for selected address
                            ShowDates();
                        }
                        if (SelectedAddress == 2) {
                            // Custom address has been selected
                            // Show and enable fields
                            pManualAddress.SetVisible(true);
                            txtAddress.SetEnabled(true);
                            ddlZipCode.SetEnabled(true);

                            // Clear text values
                            txtAddress.SetText("");
                            ddlZipCode.SetValue("");
                            txtAddress.SetFocus();
                        }
                    }

                    // Function that will show free dates based on entered address
                    function ShowDates() {
                        // Validate values
                        ddlSelectAddress.Validate();
                        txtAddress.Validate();
                        ddlZipCode.Validate();

                        var isFormValid = ASPxClientEdit.ValidateGroup("SelectAddress");
                        if (isFormValid) {
                            // Form is valid - show free dates

                            gvFreeCapacity.SetVisible(true);
//                            // Hide timeslot panel (in case new address is being selected)
//                            callbackSelectTimeslotPanel.SetVisible(false);

                            // Prepare input (0: Selected address, 1: ZipCode, 2: True/false - show all timeslots)
                            var input = ddlSelectAddress.GetValue() + '|' + ddlZipCode.GetValue() + '|' + cbShowOutSideArea.GetChecked();

                            // Do server postback
                            callbackSelectDatePanel.PerformCallback(input);

                            // Show loadingpanel while doing server postback
                            LoadingPanel.Show();
                        }
                    }

                </script>

                <!-- Select Address/Location Panel -->
                <dx:ASPxCallbackPanel ID="callbackSelectAddressPanel" ClientInstanceName="callbackSelectAddressPanel" runat="server" OnCallback="callbackSelectAddressPanel_Callback" RenderMode="Table" ClientVisible="false">
                    <ClientSideEvents EndCallback="OnSelectAddressPanelComplete" CallbackError="CallBackError" />
                    <PanelCollection>
                        <dx:PanelContent>
                            <b>Kunde</b>
                            <table>
                                <tr>
                                    <td>
                                        <dx:ASPxLabel ID="lblSelectedCustomerId" runat="server" Text="lblSelectedCustomerId">
                                        </dx:ASPxLabel>
                                    </td>
                                    <td>
                                        <dx:ASPxLabel ID="lblSelectedCustomerIdValue" ClientInstanceName="lblSelectedCustomerIdValue" runat="server" Text="">
                                        </dx:ASPxLabel>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <dx:ASPxLabel ID="lblSelectedCustomerName" runat="server" Text="Navn">
                                        </dx:ASPxLabel>
                                    </td>
                                    <td>
                                        <dx:ASPxLabel ID="lblSelectedCustomerNameValue" ClientInstanceName="lblSelectedCustomerNameValue" runat="server" Text="">
                                        </dx:ASPxLabel>
                                    </td>
                                </tr>
                            </table>
                            
                            <b>Valgt bil</b>
                            <table>
                                <tr>
                                    <td>
                                        <dx:ASPxLabel ID="lblSelectedCarRegistrationNumber" runat="server" Text="Regnr">
                                        </dx:ASPxLabel>
                                    </td>
                                    <td>
                                        <dx:ASPxLabel ID="lblSelectedCarRegistrationNumberValue" ClientInstanceName="lblSelectedCarRegistrationNumberValue" runat="server" Text="">
                                        </dx:ASPxLabel>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <dx:ASPxLabel ID="lblSelectedCarBrandDescription" runat="server" Text="Bilmærke og model">
                                        </dx:ASPxLabel>
                                    </td>
                                    <td>
                                        <dx:ASPxLabel ID="lblSelectedCarBrandDescriptionValue" ClientInstanceName="lblSelectedCarBrandDescriptionValue" runat="server" Text="">
                                        </dx:ASPxLabel>
                                    </td>
                                </tr>
                            </table>
                            <!-- Panel with info on existing booking, if exists -->
                            <dx:ASPxPanel runat="server" ID="pExistingBooking" ClientInstanceName="pExistingBooking">
                                <PanelCollection>
                                    <dx:PanelContent>
                                        <hr />
                                        <b>Eksisterende booking</b>
                                        <table>
                                            <tr>
                                                <td>
                                                    <dx:ASPxLabel ID="lblExistingBookingDate" runat="server" Text="Dato">
                                                    </dx:ASPxLabel>
                                                </td>
                                                <td>
                                                    <dx:ASPxLabel ID="lblExistingBookingDateValue" ClientInstanceName="lblExistingBookingDateValue" runat="server" Text="">
                                                    </dx:ASPxLabel>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <dx:ASPxLabel ID="lblExistingBookingTimeslot" runat="server" Text="Tidsrum">
                                                    </dx:ASPxLabel>
                                                </td>
                                                <td>
                                                    <dx:ASPxLabel ID="lblExistingBookingTimeslotValue" ClientInstanceName="lblExistingBookingTimeslotValue" runat="server" Text="">
                                                    </dx:ASPxLabel>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <dx:ASPxLabel ID="lblExistingBookingAddress" runat="server" Text="Adresse">
                                                    </dx:ASPxLabel>
                                                </td>
                                                <td>
                                                    <dx:ASPxLabel ID="lblExistingBookingAddressValue" ClientInstanceName="lblExistingBookingAddressValue" runat="server" Text="">
                                                    </dx:ASPxLabel>
                                                </td>
                                            </tr>
                                        </table>
                                    </dx:PanelContent>
                                </PanelCollection>
                            </dx:ASPxPanel>
                            <hr />
                            <b>Vælg adresse</b>
                
                            <table>
                                <tr>
                                    <td>
                                        <dx:ASPxCheckBox ID="cbShowOutSideArea" ClientInstanceName="cbShowOutSideArea" Text="Vis alle ledige tider" runat="server">
                                            <ClientSideEvents CheckedChanged="function(s, e) { ShowDates(); }" />
                                        </dx:ASPxCheckBox>
                                    </td>
                                    <td>
                                        <dx:ASPxLabel ID="lblSelectAddress" runat="server" Text="Vælg adresse">
                                        </dx:ASPxLabel>
                                    </td>
                                    <td>
                                        <dx:ASPxComboBox ID="ddlSelectAddress" ClientInstanceName="ddlSelectAddress" IncrementalFilteringMode="StartsWith" DropDownStyle="DropDownList" runat="server">
                                            <ClientSideEvents SelectedIndexChanged="function(s, e) { OnSelectAddressChanged(s); }" />
                                            <ValidationSettings CausesValidation="true" ValidationGroup="SelectAddress" RequiredField-IsRequired="true" RequiredField-ErrorText="Vælg adresse" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                                                <RequiredField IsRequired="True" ErrorText="V&#230;lg adresse"></RequiredField>
                                            </ValidationSettings>
                                        </dx:ASPxComboBox>
                                    </td>
                                </tr>
                            </table>
                            <dx:ASPxPanel runat="server" ID="pManualAddress" ClientInstanceName="pManualAddress" ClientVisible="false">
                                <PanelCollection>
                                    <dx:PanelContent>
                                        <table>
                                            <tr>
                                                <td>
                                                    <dx:ASPxLabel ID="lblAddress" ClientInstanceName="lblAddress" runat="server" Text="Vej">
                                                    </dx:ASPxLabel>
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtAddress" ClientInstanceName="txtAddress" runat="server" Width="200px" ClientEnabled="false">
                                                        <ValidationSettings CausesValidation="true" ValidationGroup="SelectAddress" RequiredField-IsRequired="true" RequiredField-ErrorText="Indtast adresse" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                                                            <RequiredField IsRequired="True" ErrorText="Indtast adresse"></RequiredField>
                                                        </ValidationSettings>
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <dx:ASPxLabel ID="lblZipCodeCity" ClientInstanceName="lblZipCodeCity" runat="server" Text="Postnr og by">
                                                    </dx:ASPxLabel>
                                                </td>
                                                <td>
                                                    <dx:ASPxComboBox ID="ddlZipCode" ClientInstanceName="ddlZipCode" IncrementalFilteringMode="Contains" ClientEnabled="false" 
                                                        DropDownWidth="200" DropDownStyle="DropDownList" runat="server" ValueField="ZipCode" TextFormatString="{0} {1}">
                                                        <ClientSideEvents SelectedIndexChanged="function(s, e) { ShowDates(); }" />
                                                        <ValidationSettings CausesValidation="true" ValidationGroup="SelectAddress" RequiredField-IsRequired="true" RequiredField-ErrorText="Vælg postnr og by" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                                                            <RequiredField IsRequired="True" ErrorText="V&#230;lg postnr og by"></RequiredField>
                                                        </ValidationSettings>
                                                        <Columns>
                                                            <dx:ListBoxColumn FieldName="ZipCode" Caption="Postnr" Width="50px" />
                                                            <dx:ListBoxColumn FieldName="City" Caption="By" Width="150px" />
                                                        </Columns>
                                                    </dx:ASPxComboBox>

                                                </td>
                                            </tr>
                                        </table>
                                    </dx:PanelContent>
                                </PanelCollection>
                            </dx:ASPxPanel>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxCallbackPanel>

                <!-- Javascript: Select date Panel  -->
                <script language="javascript" type="text/javascript">

                    function OnSelectDatePanelComplete(s, e) {
                        // Hide loadingpanel after postback
                        LoadingPanel.Hide();

                        // Show panel
                        callbackSelectDatePanel.SetVisible(true);

                        // Prepare input (0: Selected address, 1: ZipCode)
                        var input = txtAddress.GetValue() + '|' + ddlZipCode.GetValue();

                        // Refrehs gridview with cars on some location or nearby that also need service
                        gvNearByServiceDriveTasks.PerformCallback(input);
                    }

                    // Function that will show free timeslots on selected date
                    function ShowTimeSlots(s, e) {

                        //var scheduleDate = new Date(ddlSelectDate.GetValue());
                        var scheduleDate = ddlSelectDate.GetText().substring(0, 10);
                        //var stringDate = scheduleDate.getDate() + "-" + (1 + scheduleDate.getMonth()) + "-" + scheduleDate.getFullYear();
                        //var stringDate =  scheduleDate.getDate() + "-" + (1 + scheduleDate.getMonth()) + "-" + scheduleDate.getFullYear();
                        var stringDate = scheduleDate;

                        //var stringDate = parseDate(ddlSelectDate.GetText());

                        // Prepare input (0: ScheduleDate, 1: True/false - allow outside service area booking)
                        var input = stringDate + '|' + cbShowOutSideArea.GetChecked();

                        // Callback server to get available timeslots for a specific date
                        gvFreeCapacity.PerformCallback(input);

                        // Show loadingpanel while doing server postback
                        //LoadingPanel.Show();
                    }

                    // parse a date in yyyy-mm-dd format
                    function parseDate(input) {
                        var parts = input.match(/(\d+)/g);
                        // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
                        return new Date(parts[0], parts[1] - 1, parts[2]); // months are 0-based
                    }

                </script>

                <!-- Select date Panel -->
                <dx:ASPxCallbackPanel ID="callbackSelectDatePanel" ClientInstanceName="callbackSelectDatePanel" runat="server" OnCallback="callbackSelectDatePanel_Callback" RenderMode="Table" ClientVisible="false">
                    <ClientSideEvents EndCallback="OnSelectDatePanelComplete" CallbackError="CallBackError" />
                    <PanelCollection>
                        <dx:PanelContent>
                            <b>Vælg dato</b>
                            <dx:ASPxLabel ID="lblDateSearchMessage" ClientInstanceName="lblDateSearchMessage" runat="server" Text="" ClientVisible="false">
                            </dx:ASPxLabel>
                            <dx:ASPxComboBox ID="ddlSelectDate" ClientInstanceName="ddlSelectDate" IncrementalFilteringMode="StartsWith" DropDownStyle="DropDownList" runat="server" DisplayFormatString="d">
                                <ClientSideEvents SelectedIndexChanged="function(s, e) { ShowTimeSlots(); }" />
                                <ValidationSettings CausesValidation="true" ValidationGroup="SelectDate" RequiredField-IsRequired="true" RequiredField-ErrorText="Vælg dato" SetFocusOnError="true" ErrorDisplayMode="ImageWithTooltip">
                                    <RequiredField IsRequired="True" ErrorText="V&#230;lg dato"></RequiredField>
                                </ValidationSettings>
                            </dx:ASPxComboBox>

                            <!-- TODO: Tilføj mulighed for at angive udvidet oplysninger efter booking -> åbner popup hvor dette kan gøres -->

                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxCallbackPanel>

                <!-- Javascript: Functions for dayplan  -->
                <script language="javascript" type="text/javascript">

                    // Function bookes selected service
                    function BookService(serviceid) {
                        BookSelectedServiceDriveTask(TaskId, serviceid)
                    }

                    function BookSelectedServiceDriveTask(taskid, serviceid) {
                        if (taskid == null | taskid == 0) {
                            alert('Ingen servicekørsel valgt - venligst vælg en servicekørsel og book igen.');
                        }
                        else {

                            // (0: taskid, 1: servicescheduledetailid, 2: address, 3: zipcode, 4: allow booking outside area - true/false (optional))
                            var input = taskid + '|' + serviceid + '|' + txtAddress.GetValue() + '|' + ddlZipCode.GetValue() + '|' + cbShowOutSideArea.GetChecked();

                            // Run callback function to book selected service drive task
                            callBookService.PerformCallback(input);
                        }
                    }

                    // Function that deletes booked service
                    function DeleteBookedService(serviceid) {

                        var answer = confirm("Slet booking/blokering?")
                        if (answer) {
                            // Run callback function to delete booked service
                            callDeleteBookedService.PerformCallback(serviceid);
                        }
                    }

                    function OnCallbackBookServiceComplete() {
                        // Hide panels
                        callbackSelectAddressPanel.SetVisible(false);
                        callbackSelectDatePanel.SetVisible(false);
                        //callbackSelectTimeslotPanel.SetVisible(false);

                        // Show selected task details and possible date depending on address selection
                        callbackSelectAddressPanel.PerformCallback(TaskId);

                        // Show loadingpanel while doing server postback
                        LoadingPanel.Show();

                        // Refresh gridviews
                        var scheduleDate = ddlSelectDate.GetText().substring(0, 10);
                        
                        // Prepare input (0: ScheduleDate, 1: True/false - allow outside service area booking)
                        var input = scheduleDate + '|' + cbShowOutSideArea.GetChecked();

                        gvFreeCapacity.PerformCallback(input);
                        gvServiceDriveTasks.PerformCallback();

                        // TODO: Make extended booking options (confirm+send confirm mail, ask for confirm mail, confirm-mail, add note (tilføjes senere da tilføj note gør det lidt mere "kompliseret" ved redigering
//                        // Clear form fields
//                        cbCustomerConfirmed.SetChecked(false);
//                        txtNote.SetText('');
                    }

                    function OnCallbackDeleteBookedServiceComplete(s, e) {
                        // Refresh gridviews
                        var scheduleDate = ddlSelectDate.GetText().substring(0, 10);

                        // Prepare input (0: ScheduleDate, 1: True/false - allow outside service area booking)
                        var input = scheduleDate + '|' + cbShowOutSideArea.GetChecked();

                        gvFreeCapacity.PerformCallback(input);
                        gvServiceDriveTasks.PerformCallback();

                        if (e.result == TaskId) {
                            // Selected task for edit has been deleted, update UI
                            
                            // Show selected task details and possible date depending on address selection
                            callbackSelectAddressPanel.PerformCallback(TaskId);

                            // Show loadingpanel while doing server postback
                            LoadingPanel.Show();
                        }
                    }

                    // How to implement UserControl in page - EditServiceScheduleDetailNote
                    // Functions for edit serviceschedule detail notes modalpopup
                    function EditServiceScheduleDetailNoteModalPopup(element, key) {
                        callbackEditServiceScheduleDetailNotePanel.SetContentHtml("");
                        pcEditServiceScheduleDetailNote.ShowAtElement(element);
                        callbackEditServiceScheduleDetailNotePanel.PerformCallback(key);
                        EditServiceScheduleDetailNoteKeyValue = key;
                    }

                    function EditServiceScheduleDetailNoteRefreshParent() {
                        //Perform action on parent control - ex. refresh gridview with PerformCallback
                        
                        // Nothing
                    }

                    // Function that select and existing booking and show details and for changing/editing
                    function SelectBookedServiceDriveTask(s, e) {
                        // Get taskid
                        //gvFreeCapacity.GetRowValues(gvFreeCapacity.GetFocusedRowIndex(), 'TaskId', SetSelectedServiceDriveTaskId);
                    }

                    // Function that selects a booked service in gridview for editing/changing
                    function ChangeBookedService(index) {
                        gvFreeCapacity.GetRowValues(index, 'TaskId', SetSelectedServiceDriveTaskId);
//                        var taskid = gvFreeCapacity.GetRowValuesByKeyValue(serviceid, 'TaskId');
//                        SetSelectedServiceDriveTaskId(taskid);
                    }

                </script>
                
                <!-- Gridview with possible booking timeslots -->
                <dx:ASPxGridView ID="gvFreeCapacity" runat="server" Caption="Dagsplan" Width="300px"
                    KeyFieldName="ServiceCarScheduleDetailId" ClientVisible="false" 
                    AutoGenerateColumns="False" ClientInstanceName="gvFreeCapacity"
                    OnCustomCallback="gvFreeCapacity_CustomCallback" OnHtmlRowPrepared="gvFreeCapacity_HtmlRowPrepared">
                    <SettingsBehavior ProcessFocusedRowChangedOnServer="false" AllowFocusedRow="true" />
                    <ClientSideEvents FocusedRowChanged="function(s, e) { SelectBookedServiceDriveTask() }" 
                                        CustomButtonClick="function(s, e) {
	                                    if(e.buttonID == 'selectBookedServiceTask'){
                                                            
                                                             ChangeBookedService(e.visibleIndex);
                                                         }
                                        }" />
                    <SettingsPager AlwaysShowPager="False" PageSize="100" Position="Bottom">
                        <Summary 
                            AllPagesText="Sider: {0} - {1} ({2} plads)" 
                            Text="Side {0} af {1} ({2} plads)" />
                    </SettingsPager>
                    <Columns>
                        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                                <HeaderTemplate>
                                    <input type="checkbox" onclick="gvFreeCapacity.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                                </HeaderTemplate>
                                <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                    HorizontalAlign="Center">
                                <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                                </HeaderStyle>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataColumn VisibleIndex="0">
                            <DataItemTemplate>
                                <dx:ASPxButton ID="btnDelete" runat="server" ClientInstanceName="btnDelete" Text="Slet" ToolTip="Klik for at slette booket servicekørsel" AutoPostBack="false"
                                    ClientSideEvents-Click='<%# "function(s, e) { DeleteBookedService(" + Container.KeyValue + "); }" %>'>
                                </dx:ASPxButton>                                           
                            </DataItemTemplate>
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="3" Caption="Kundenr">
                            <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomerData.aspx?CustomerId={0}" TextField="CustomerId" Target="_blank">
                            </PropertiesHyperLinkEdit>
                        </dx:GridViewDataHyperLinkColumn>
                        <dx:GridViewDataTextColumn FieldName="ServiceCarScheduleDetailId" Visible="false" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn FieldName="TaskId" Visible="false" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn FieldName="ScheduleDate" Visible="false" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn FieldName="ServiceCarId" Visible="true" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn FieldName="ToLongitude" Visible="false" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn FieldName="ToLatitude" Visible="false" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn FieldName="CarId" Visible="false" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn FieldName="ContainerId" Visible="false" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn FieldName="ScheduleDetailTypeId" Visible="false" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn FieldName="Note" Visible="false" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn Caption="Start" FieldName="StartTime" VisibleIndex="0" />
                        <dx:GridViewDataTextColumn Caption="Slut" FieldName="EndTime" VisibleIndex="1" />
                        <dx:GridViewDataTextColumn Caption="Navn" FieldName="Name" VisibleIndex="2" />
                        <dx:GridViewDataTextColumn Caption="Adresse" FieldName="ToAddress" VisibleIndex="3" />
                        <dx:GridViewDataTextColumn Caption="Postnr" FieldName="ToZipCode" VisibleIndex="4" />
                        <dx:GridViewDataTextColumn Caption="By" FieldName="ToCity" VisibleIndex="5" />
                        <dx:GridViewDataTextColumn Caption="Telefon1" FieldName="Phone1" VisibleIndex="6" />
                        <dx:GridViewDataTextColumn Caption="Reg.nr." FieldName="RegistrationNumber" VisibleIndex="7" />
                        <dx:GridViewDataTextColumn Caption="Bil" FieldName="CarBrandDescription" VisibleIndex="7" />
                        <dx:GridViewDataTextColumn FieldName="CustomerConfirmed" VisibleIndex="8" Visible="false" />
                        <dx:GridViewDataColumn>
                            <DataItemTemplate>
                                <dx:ASPxImage ID="imgNote" Visible='<%# (Convert.ToString(Eval("Note")) != "") %>' ImageUrl="~/Images/Tiny/about.png" runat="server" 
                                    ClientSideEvents-Click='<%# "function(s, e) { EditServiceScheduleDetailNoteModalPopup(this," + Container.KeyValue + "); }" %>'>
                                </dx:ASPxImage>
                            </DataItemTemplate>
                        </dx:GridViewDataColumn>
                        <dx:GridViewCommandColumn>
                            <CustomButtons>
                                <dx:GridViewCommandColumnCustomButton ID="selectBookedServiceTask" Text="Vælg">
                                </dx:GridViewCommandColumnCustomButton>
                            </CustomButtons>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataColumn>
                            <DataItemTemplate>
                                <dx:ASPxButton ID="btnInsert" runat="server" ClientInstanceName="btnInsert" Text="+" ToolTip="Klik for at book valgte bil i dette tidsrum" AutoPostBack="false"
                                    ClientSideEvents-Click='<%# "function(s, e) { BookService(" + Container.KeyValue + "); }" %>'>
                                </dx:ASPxButton>                                           
                            </DataItemTemplate>
                        </dx:GridViewDataColumn>
                    </Columns>
                    <SettingsLoadingPanel Mode="ShowOnStatusBar" />
                    <Styles>
                        <Header ImageSpacing="5px" SortingImageSpacing="5px" />
                    </Styles>
                </dx:ASPxGridView>

                <dx:ASPxCallback ID="callBookService" ClientInstanceName="callBookService" runat="server" OnCallback="callBookService_Callback">
                    <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackBookServiceComplete" />
                </dx:ASPxCallback>

                <dx:ASPxCallback ID="callDeleteBookedService" ClientInstanceName="callDeleteBookedService" runat="server" OnCallback="callDeleteBookedService_Callback">
                    <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackDeleteBookedServiceComplete" />
                </dx:ASPxCallback>

                <%--<dx:ASPxCallback ID="callBackManageCustomerApproval" ClientInstanceName="callBackManageCustomerApproval" runat="server" OnCallback="callBackManageCustomerApproval_Callback">
                    <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackManageCustomerApprovalComplete" />
                </dx:ASPxCallback>--%>

            </td>
        </tr>
        <tr>
            <td valign="top">

                <!-- Javascript: Functions for Near By ServiceDriveTasks -->
                <script language="javascript" type="text/javascript">

                    // Function that runs when task is selected in gridview
                    function SelectedNearByServiceDriveTaskChanged(s, e) {
                        // Get taskid
                        //gvNearByServiceDriveTasks.GetRowValues(gvNearByServiceDriveTasks.GetFocusedRowIndex(), 'TaskId', SetSelectedServiceDriveTaskId);
                    }

                    // Function that selects a booked service in gridview for editing/changing
                    function SelectNearbyService(index) {
                        gvNearByServiceDriveTasks.GetRowValues(index, 'TaskId', SetSelectedServiceDriveTaskId);
//                        var taskid = gvNearByServiceDriveTasks.GetRowValuesByKeyValue(serviceid, 'TaskId');
//                        SetSelectedServiceDriveTaskId(taskid);
                    }

                </script>

                <!-- Contains overview of close by service drives based on selected service drive -->
                <!-- Contains overview of pending servicedrives -->
                <dx:ASPxGridView ID="gvNearByServiceDriveTasks" runat="server" Caption="Servicekørsler i nærheden" ClientVisible="false" 
                    ClientInstanceName="gvNearByServiceDriveTasks" Width="300px" KeyFieldName="TaskId" AutoGenerateColumns="False" 
                    EnableCallBacks="True" OnCustomCallback="gvNearByServiceDriveTasks_CustomCallback">
                    <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                    <Border BorderWidth="0px" />
                    <Settings ShowVerticalScrollBar="true" ShowHeaderFilterButton="true" ShowGroupPanel="false" ShowFilterRow="true" />
                    <SettingsPager AlwaysShowPager="False" PageSize="100" Position="Bottom">
                        <Summary 
                            AllPagesText="Sider: {0} - {1} ({2} servicekørsler)" 
                            Text="Side {0} af {1} ({2} servicekørsler)" />
                    </SettingsPager>
                    <SettingsBehavior ProcessFocusedRowChangedOnServer="false" AllowFocusedRow="true" ConfirmDelete="True" AllowGroup="false" AllowDragDrop="false" />
                    <ClientSideEvents FocusedRowChanged="function(s, e) { SelectedNearByServiceDriveTaskChanged() }" 
                                        CustomButtonClick="function(s, e) {
	                                    if(e.buttonID == 'selectNearByServiceTask'){
                                                            
                                                             SelectNearbyService(e.visibleIndex);
                                                         }
                                        }" />
                    <Columns>
                        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                            <HeaderTemplate>
                                <input type="checkbox" onclick="gvNearByServiceDriveTasks.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                            </HeaderTemplate>
                            <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                HorizontalAlign="Center">
                            <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                            </HeaderStyle>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataColumn FieldName="TaskId" Visible="false" VisibleIndex="3" Caption="TaskId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="CarId" Visible="false" VisibleIndex="4" Caption="CarId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="CustomerId" Visible="false" VisibleIndex="5" Caption="CustomerId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="TireSetId" Visible="false" VisibleIndex="6" Caption="TireSetId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="ContainerId" Visible="false" VisibleIndex="7" Caption="ContainerId">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryLongitude" Visible="false" VisibleIndex="8" Caption="PrimaryLongitude">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryLatitude" Visible="false" VisibleIndex="9" Caption="PrimaryLatitude">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="SecondaryLongitude" Visible="false" VisibleIndex="10" Caption="SecondaryLongitude">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="SecondaryLatitude" Visible="false" VisibleIndex="11" Caption="SecondaryLatitude">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataTextColumn FieldName="ContainerNumber" VisibleIndex="12" Visible="false" Caption="Lager">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="13" Caption="Reg.nr.">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="14" Caption="Kundenr">
                            <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomerData.aspx?CustomerId={0}" TextField="CustomerId" Target="_blank">
                            </PropertiesHyperLinkEdit>
                        </dx:GridViewDataHyperLinkColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryAddress" VisibleIndex="15" Visible="false" Caption="Adresse">
                        </dx:GridViewDataColumn>
                        <%--<dx:GridViewDataColumn FieldName="PrimaryZipCode" VisibleIndex="16" Caption="Postnr" ToolTip='<%# Eval("PrimaryAddress") + " " + Eval("PrimaryCity") %>'>
                        </dx:GridViewDataColumn>--%>
                        <dx:GridViewDataColumn FieldName="PrimaryZipCode" VisibleIndex="16" Caption="Postnr">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryCity" VisibleIndex="17" Caption="By">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="PrimaryCountryId" VisibleIndex="18" Caption="PrimaryCountryId" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="SecondaryAddress" VisibleIndex="19" Caption="Sek. Adr" Visible="false">
                        </dx:GridViewDataColumn>          
                        <%--<dx:GridViewDataColumn FieldName="SecondaryZipCode" VisibleIndex="20" Caption="Sek. Postnr" ToolTip='<%# Eval("SecondaryAddress") + " " + Eval("SecondaryCity") %>'>
                        </dx:GridViewDataColumn>--%>
                        <dx:GridViewDataColumn FieldName="SecondaryZipCode" VisibleIndex="20" Caption="Sek. Postnr">
                        </dx:GridViewDataColumn>          
                        <dx:GridViewDataColumn FieldName="SecondaryCity" VisibleIndex="21" Caption="Sek. By" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="Distance" VisibleIndex="22" Caption="Km pri." ToolTip="Afstand fra lager til kundens primære adresse" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewDataColumn FieldName="DistanceSecondary" VisibleIndex="23" Caption="Km sek." ToolTip="Afstand fra lager til kundens sekundære adresse" Visible="false">
                        </dx:GridViewDataColumn>
                        <dx:GridViewCommandColumn>
                            <CustomButtons>
                                <dx:GridViewCommandColumnCustomButton ID="selectNearByServiceTask" Text="Vælg">
                                </dx:GridViewCommandColumnCustomButton>
                            </CustomButtons>
                        </dx:GridViewCommandColumn>
                    </Columns>
                    <%--<Templates>
                        <DetailRow>
                            Opgavedetaljer
                            <br />
                            <dx:ASPxGridView ID="gvTaskDetail" ClientInstanceName="gvTaskDetail" runat="server" KeyFieldName="TaskDetailId"
                                Width="100%" OnBeforePerformDataSelect="gvTaskDetail_DataSelect">
                                <Columns>
                                    <dx:GridViewDataColumn FieldName="TaskDetailId" Caption="Id" VisibleIndex="1" />
                                    <dx:GridViewDataColumn FieldName="TaskDetailTypeId" Caption="Type" Visible="false" VisibleIndex="2" />
                                    <dx:GridViewDataColumn FieldName="Description" Caption="Beskrivelse" VisibleIndex="2" />
                                    <dx:GridViewDataColumn FieldName="EstimatedTime" Caption="Estimeret tid" VisibleIndex="2" />
                                    <dx:GridViewDataColumn FieldName="Amount" Caption="Antal" VisibleIndex="3" />
                                    <dx:GridViewDataColumn FieldName="NoteToEmployee" Caption="Note" VisibleIndex="4" />
                                    <dx:GridViewDataColumn FieldName="Completed" Caption="Afsluttet" VisibleIndex="5" />
                                    <dx:GridViewDataColumn FieldName="Cancelled" Caption="Annulleret" VisibleIndex="6" />
                                </Columns>
                            </dx:ASPxGridView>
                        </DetailRow>
                    </Templates>--%>
                    <SettingsDetail ShowDetailRow="true" />                                            
                </dx:ASPxGridView>
            </td>
        </tr>
    </table>

    <uc2:ucEditServiceNote ID="ucEditServiceNote" runat="server" ViewStateMode="Enabled" />

</asp:Content>
